
<h1>Data Collections
  <%= image_tag("spinner.gif",
    :align => "absmiddle",
    :border => 0,
    :id => "spinner",
    :style => "display: none;") %>
</h1>


<div id="filterBox">
  Filters (
  <a href="#" onClick="$('filterTable').show(); return false;">show</a>
  |
  <a href="#" onClick="$('filterTable').hide(); return false;">hide</a>
  )


  <div id="filterTable">
    <form id="filter_form" name="filter_form" action="">

      <hr />

      <table>
        <tr>
          <th>Type</th>
          <th>Status</th>
          <th>Institution</th>
          <th>Data collector</th>
        </tr>

        <tr>
          <td>
            <% DataCollectionType.find(:all).each do |t| %>
              <%= check_box_tag "data_collection[data_collection_type_id][]", t.id %>
              <%= t.name %><br />
            <% end %>
          </td>


          <td>
            <% DataCollection.get_statuses.each do |s| %>
              <%= check_box_tag "data_collection_status[]", s %>
              <%= s %><br />
            <% end %>
          </td>
          
          <td>
            <% Institution.find(:all).each do |i| %>
              <%= check_box_tag "data_collection[youths.institution_id][]", i.id %>
              <%= i.name %><br />
            <% end %>
          </td>
          
          <td>
            <% DataCollector.find(:all).each do |dc| %>
              <%= check_box_tag "data_collection[youths.data_collector_id][]", dc.id %>
              <%= dc.name %><br />
            <% end %>
          </td>
        </tr>
      </table>
    </form>
  </div>
</div>

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
  <!--
  $('filterTable').hide();
  //-->
</SCRIPT>

<%= observe_form 'filter_form',
  :update => 'resultSet',
  :before => "Element.show('spinner')",
  :success => "Element.hide('spinner')",
  :url => {:action => 'list'},
  :with => "Form.serialize('filter_form')" %>




<div id="resultSet">
  <%= render :partial => 'data_collections_list' %>
</div>
